<?php
namespace ManagerX\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        if(session('?user')){
            $title = M('config')->where(array('name'=>'title'))->find();
            $version = M('config')->where(array('name'=>'ver'))->find();
            
            $this->assign('user', session('user.username'));
            $this->assign('role', session('user.role'));
            $this->assign('title', $title['value']);
            $this->assign('version', $version['value']);
            $this->display('index');
        }else{
            $this->redirect('User/login');
        }
    }

    public function console(){
        if(session('?user')){
            $title = M('config')->where(array('name'=>'title'))->find();
            $version = M('config')->where(array('name'=>'ver'))->find();
            $count['user'] = M('admin')->count();
            $count['project'] = M('project')->count();
            $count['data'] = M('project_data')->count();
            $count['payload'] = M('payload')->count();
            $count['template'] = M('template')->count();
            $count['notice'] = M('notice')->count();
            
            $this->assign('user', session('user.username'));
            $this->assign('title', $title['value']);
            $this->assign('version', $version['value']);
            $this->assign('os', php_uname('s'));
            $this->assign('php', phpversion());
            $this->assign('count', $count);
            $this->assign('co');
            $this->display('console');
        }else{
            $this->redirect('User/login');
        }
    }
}